var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/functionalComponent/table/base/index.tsx
var base_exports = {};
__export(base_exports, {
  default: () => base_default
});
module.exports = __toCommonJS(base_exports);
var import_antd = require("antd");
var import_react = __toESM(require("react"));
var import_react_sortable_hoc = require("react-sortable-hoc");
var import_Button = require("../../antd/Button");
var import_util = require("../util");
var import_common = require("./common");
var import_factory = __toESM(require("./factory"));
var DEFAULT_ESTIMATED_ITEM_SIZE = 50;
var getEstimatedTotalHeight = ({ rowCount }, { rowMetadataMap, estimatedRowHeight, lastMeasuredRowIndex }) => {
  let totalSizeOfMeasuredRows = 0;
  if (lastMeasuredRowIndex >= rowCount) {
    lastMeasuredRowIndex = rowCount - 1;
  }
  if (lastMeasuredRowIndex >= 0) {
    const itemMetadata = rowMetadataMap[lastMeasuredRowIndex];
    totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
  }
  const numUnmeasuredItems = rowCount - lastMeasuredRowIndex - 1;
  const totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedRowHeight;
  return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
};
var getEstimatedTotalWidth = ({ columnCount }, { columnMetadataMap, estimatedColumnWidth, lastMeasuredColumnIndex }) => {
  let totalSizeOfMeasuredRows = 0;
  if (lastMeasuredColumnIndex >= columnCount) {
    lastMeasuredColumnIndex = columnCount - 1;
  }
  if (lastMeasuredColumnIndex >= 0) {
    const itemMetadata = columnMetadataMap[lastMeasuredColumnIndex];
    totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
  }
  const numUnmeasuredItems = columnCount - lastMeasuredColumnIndex - 1;
  const totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedColumnWidth;
  return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
};
var getItemMetadata = (itemType, props, index, instanceProps) => {
  let itemMetadataMap, itemSize, lastMeasuredIndex;
  if (itemType === "column") {
    itemMetadataMap = instanceProps.columnMetadataMap;
    itemSize = props.columnWidth;
    lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
  } else {
    itemMetadataMap = instanceProps.rowMetadataMap;
    itemSize = props.rowHeight;
    lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
  }
  if (index > lastMeasuredIndex) {
    let offset = 0;
    if (lastMeasuredIndex >= 0) {
      const itemMetadata = itemMetadataMap[lastMeasuredIndex];
      offset = itemMetadata.offset + itemMetadata.size;
    }
    for (let i = lastMeasuredIndex + 1; i <= index; i++) {
      let size = itemSize(i);
      itemMetadataMap[i] = {
        offset,
        size
      };
      offset += size;
    }
    if (itemType === "column") {
      instanceProps.lastMeasuredColumnIndex = index;
    } else {
      instanceProps.lastMeasuredRowIndex = index;
    }
  }
  return itemMetadataMap[index];
};
var findNearestItem = (itemType, props, instanceProps, offset) => {
  let itemMetadataMap, lastMeasuredIndex;
  if (itemType === "column") {
    itemMetadataMap = instanceProps.columnMetadataMap;
    lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
  } else {
    itemMetadataMap = instanceProps.rowMetadataMap;
    lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
  }
  const lastMeasuredItemOffset = lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
  if (lastMeasuredItemOffset >= offset) {
    return findNearestItemBinarySearch(itemType, props, instanceProps, lastMeasuredIndex, 0, offset);
  } else {
    return findNearestItemExponentialSearch(itemType, props, instanceProps, Math.max(0, lastMeasuredIndex), offset);
  }
};
var findNearestItemBinarySearch = (itemType, props, instanceProps, high, low, offset) => {
  while (low <= high) {
    const middle = low + Math.floor((high - low) / 2);
    const currentOffset = getItemMetadata(itemType, props, middle, instanceProps).offset;
    if (currentOffset === offset) {
      return middle;
    } else if (currentOffset < offset) {
      low = middle + 1;
    } else if (currentOffset > offset) {
      high = middle - 1;
    }
  }
  if (low > 0) {
    return low - 1;
  } else {
    return 0;
  }
};
var findNearestItemExponentialSearch = (itemType, props, instanceProps, index, offset) => {
  const itemCount = itemType === "column" ? props.columnCount : props.rowCount;
  let interval = 1;
  while (index < itemCount && getItemMetadata(itemType, props, index, instanceProps).offset < offset) {
    index += interval;
    interval *= 2;
  }
  return findNearestItemBinarySearch(
    itemType,
    props,
    instanceProps,
    Math.min(index, itemCount - 1),
    Math.floor(index / 2),
    offset
  );
};
var getOffsetForIndexAndAlignment = (itemType, props, index, align, scrollOffset, instanceProps, scrollbarSize) => {
  var _a, _b;
  const {
    itemData: { fixedColumns, aggregates = [] }
  } = props;
  const offset = itemType === "column" ? (((_a = fixedColumns == null ? void 0 : fixedColumns.left) == null ? void 0 : _a.width) || 0) + (((_b = fixedColumns == null ? void 0 : fixedColumns.right) == null ? void 0 : _b.width) || 0) : 0;
  const size = itemType === "column" ? props.width : props.height - (aggregates.length > 0 ? aggregates.length * 21 + 10 : 0);
  const itemMetadata = getItemMetadata(itemType, props, index, instanceProps);
  const estimatedTotalSize = itemType === "column" ? getEstimatedTotalWidth(props, instanceProps) + offset : getEstimatedTotalHeight(props, instanceProps);
  const maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
  const minOffset = Math.max(0, itemMetadata.offset - size + offset + scrollbarSize + itemMetadata.size);
  if (align === "smart") {
    if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
      align = "auto";
    } else {
      align = "center";
    }
  }
  switch (align) {
    case "start":
      return maxOffset;
    case "end":
      return minOffset;
    case "center":
      return Math.round(minOffset + (maxOffset - minOffset) / 2);
    case "auto":
    default:
      if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
        return scrollOffset;
      } else if (minOffset > maxOffset) {
        return minOffset;
      } else if (scrollOffset < minOffset) {
        return minOffset;
      } else {
        return maxOffset;
      }
  }
};
var Row = import_react.default.memo(
  ({ delayLoading, isGroup, style, scrollingStyle, rowIndex, children }) => {
    const {
      table,
      table: { props },
      columns: { fixedColumns }
    } = (0, import_react.useContext)(import_common.TableContext);
    const [keyField, row] = [table.getKeyField(), table.getRow(rowIndex)];
    const keyValue = row[keyField];
    const checkedIndex = table.getCheckBoxDataIndex();
    const checked = row[checkedIndex];
    const highlight = (0, import_react.useRef)(false);
    highlight.current = table.getSelectedKeys(true).has(keyValue);
    const [, forceUpdate] = (0, import_react.useState)({});
    const delayClick = (0, import_react.useRef)(false);
    table._setKeyMap(row);
    (0, import_react.useEffect)(() => {
      return table.subscribe(({ rowIndex: rIndex, incompatible }) => {
        const newHighlight = table.getSelectedKeys(true).has(keyValue);
        if (newHighlight !== highlight.current && !table._setCheckedByRowSelection(rowIndex, newHighlight, incompatible)) {
          forceUpdate({});
        }
      }, "clickHighlight");
    }, [keyValue]);
    (0, import_react.useEffect)(() => {
      if (row.__update__) {
        delete row.__update__;
      }
    }, [row.__update__]);
    (0, import_react.useEffect)(() => {
      return () => {
        table._setKeyMap(row, true);
      };
    }, []);
    (0, import_react.useMemo)(() => {
      if (table.isMultipleInterval() && table.props.checkbox) {
        checked ? table._selectedKeys.add(keyValue) : table._selectedKeys.delete(keyValue);
        highlight.current = !!checked;
        if (!highlight.current && table._lastHighlightRowIndex === rowIndex) {
          table._lastHighlightRowIndex = -1;
        }
      }
    }, [checked, keyValue]);
    if (delayLoading) {
      return /* @__PURE__ */ import_react.default.createElement("div", { style }, /* @__PURE__ */ import_react.default.createElement("div", { className: "row-loading", style: scrollingStyle }));
    }
    const onRow = props.onRow && !isGroup ? props.onRow(rowIndex, table, row) : {};
    const selectedCls = props.rowChecked && checked ? " row-selected" : "";
    const highlightCls = highlight.current ? ` ${props.rowChecked ? "row-active" : "row-selected"}` : "";
    const { style: rowStyle, className: rowClassName, onClick, onSelect, rowRender, ...others } = onRow || {};
    const delay = async (ms = 300) => {
      await import_util.util.delay(ms);
      delayClick.current = false;
    };
    const rowProps = {
      ...others,
      onMouseDown: (e) => {
        if (e.ctrlKey || e.shiftKey) {
          e.preventDefault();
        }
      },
      onClick: async (e) => {
        var _a;
        if (isGroup || delayClick.current) {
          return;
        }
        delayClick.current = true;
        const cell = import_util.util.closest(e.target, (el) => el.classList.contains("virtual-table-cell"));
        if ((_a = cell == null ? void 0 : cell.dataset) == null ? void 0 : _a.key) {
          const result = await table.notify({ table, dataIndex: cell.dataset.key, row }, "onCellClick");
          if (result.some((r) => r === false)) {
            return await delay(300);
          }
        }
        const disableSelected = table.isRowSelectionDisabled(row);
        if (!disableSelected) {
          if (await (onSelect == null ? void 0 : onSelect(e)) === false) {
            return await delay(300);
          }
          if (props.rowChecked && props.checkbox && !checked) {
            table.setSelected(rowIndex, true);
          }
          if (props.rowSelected) {
            table.setHighlight(rowIndex, { ctrlKey: e.ctrlKey, shiftKey: e.shiftKey });
            if (props.activeCellEditor === "doubleClick" && table.state.selected.rowIndex !== rowIndex) {
              table.endEditing(true);
            }
          }
        }
        await (onClick == null ? void 0 : onClick(e));
        return await delay(300);
      },
      style: {
        ...rowStyle,
        ...style,
        cursor: (table.props.rowChecked || table.props.rowSelected) && !selectedCls && !highlightCls && !isGroup ? "pointer" : ""
      },
      className: `${isGroup ? "table-group-row" : "table-row"} index-${rowIndex}${rowClassName ? " " + rowClassName : ""}${selectedCls}${highlightCls}`,
      children: rowRender ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, rowRender({
        style: {
          top: 0,
          height: style.height,
          left: style.left + fixedColumns.left.width,
          zIndex: 1,
          position: "absolute"
        }
      }), children) : children
    };
    return /* @__PURE__ */ import_react.default.createElement("div", { ...rowProps });
  },
  (p, n) => {
    return n.delayLoading && !p.delayLoading;
  }
);
function isEditing(itemData, rowIndex, columnIndex) {
  const selected = (itemData == null ? void 0 : itemData.table.state.selected) || { editing: false };
  if (columnIndex > -1) {
    return selected.editing && selected.rowIndex === rowIndex && selected.dataIndex === itemData.columns[columnIndex].dataIndex;
  } else {
    return selected.editing && selected.rowIndex === rowIndex ? selected.rowIndex + ":" + selected.dataIndex : ":";
  }
}
function isActive(itemData, rowIndex, columnIndex) {
  const disabled = !!(itemData == null ? void 0 : itemData.table.props.disabled);
  if (disabled)
    return columnIndex > -1 ? false : ":";
  const selected = (itemData == null ? void 0 : itemData.table.state.selected) || { editing: false };
  if (columnIndex > -1) {
    return !selected.editing && selected.rowIndex === rowIndex && selected.dataIndex === itemData.columns[columnIndex].dataIndex;
  } else {
    return !selected.editing && selected.rowIndex === rowIndex ? selected.rowIndex + ":" + selected.dataIndex : ":";
  }
}
function createCellNode({ children, columnIndex, rowIndex, data, itemData, edit = false, ...others }) {
  var _a;
  return (0, import_react.createElement)(children, {
    data,
    columnIndex,
    rowIndex,
    table: itemData.table,
    key: `${rowIndex}:${((_a = itemData.columns[columnIndex]) == null ? void 0 : _a.dataIndex) || columnIndex}`,
    ...edit ? {
      active: isActive(itemData, rowIndex, columnIndex),
      editing: isEditing(itemData, rowIndex, columnIndex)
    } : {},
    ...others
  });
}
function optimize(instance) {
  const { itemData, useIsScrolling } = instance.props;
  const { isScrolling, scrollLeft, scrollTop } = instance.state;
  let delayLoading = useIsScrolling && isScrolling;
  if (!itemData.memoLastScroll) {
    itemData.memoLastScroll = { scrollLeft, scrollTop };
  }
  if (delayLoading) {
    if (itemData.memoLastScroll.scrollLeft !== scrollLeft && itemData.memoLastScroll.scrollTop === scrollTop) {
      delayLoading = false;
    } else {
      const abs = Math.abs(scrollTop - itemData.memoLastScroll.scrollTop);
      if (abs > 0 && abs < 760) {
        delayLoading = false;
      }
    }
  }
  itemData.delayLoading = delayLoading;
  itemData.memoLastScroll = { scrollLeft, scrollTop };
  return delayLoading;
}
function getTotalWidth(instance) {
  var _a;
  const { itemData, width } = instance.props;
  const { scrollLeft } = instance.state;
  const addFixedColumn = itemData.fixedColumns && (itemData.fixedColumns.left.columns.length > 0 || itemData.fixedColumns.right.columns.length > 0);
  let totalWidth = itemData.totalColumnWidth;
  if (addFixedColumn && itemData.table && ((_a = itemData.table.containerRef) == null ? void 0 : _a.current)) {
    let containerClassName = itemData.table.containerRef.current.className.replace(
      /(\s*scroll-leave-left)|(\s*scroll-leave-right)/g,
      ""
    );
    if (width < totalWidth) {
      if (scrollLeft > 0) {
        containerClassName += " scroll-leave-left";
      }
      if (scrollLeft < totalWidth - width) {
        containerClassName += " scroll-leave-right";
      }
    }
    if (containerClassName !== itemData.table.containerRef.current.className) {
      itemData.table.containerRef.current.className = containerClassName;
    }
  }
  return totalWidth;
}
function createAggregateItems(instance, fixedRight, rowIndex, columnStartIndex, columnStopIndex, ds) {
  const { children, itemData, columnCount } = instance.props;
  const addFixedColumn = itemData.fixedColumns && (itemData.fixedColumns.left.columns.length > 0 || itemData.fixedColumns.right.columns.length > 0);
  const aggregateItems = [];
  if (addFixedColumn) {
    aggregateItems.push(
      createCellNode({
        children,
        columnIndex: -1,
        fixedRight,
        rowIndex,
        cellType: import_common.CellTypeEnum.AggregateCell,
        itemData,
        data: itemData.dataSource,
        subDataSource: ds,
        style: {
          ...instance._getItemStyle(0, 0),
          top: 0
        }
      })
    );
  }
  if (columnCount > 0) {
    for (let columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) {
      aggregateItems.push(
        createCellNode({
          children,
          rowIndex,
          columnIndex,
          cellType: import_common.CellTypeEnum.AggregateCell,
          itemData,
          data: itemData,
          subDataSource: ds,
          style: {
            ...instance._getItemStyle(0, columnIndex),
            top: 0
          }
        })
      );
    }
  }
  return aggregateItems;
}
var VariableSizeGrid = (0, import_factory.default)({
  getColumnOffset: (props, index, instanceProps) => getItemMetadata("column", props, index, instanceProps).offset,
  getColumnStartIndexForOffset: (props, scrollLeft, instanceProps) => findNearestItem("column", props, instanceProps, scrollLeft),
  getColumnStopIndexForStartIndex: (props, startIndex, scrollLeft, instanceProps) => {
    const { columnCount, width } = props;
    const itemMetadata = getItemMetadata("column", props, startIndex, instanceProps);
    const maxOffset = scrollLeft + width;
    let offset = itemMetadata.offset + itemMetadata.size;
    let stopIndex = startIndex;
    while (stopIndex < columnCount - 1 && offset < maxOffset) {
      stopIndex++;
      offset += getItemMetadata("column", props, stopIndex, instanceProps).size;
    }
    return stopIndex;
  },
  getColumnWidth: (props, index, instanceProps) => instanceProps.columnMetadataMap[index].size,
  getEstimatedTotalHeight,
  getEstimatedTotalWidth,
  getOffsetForColumnAndAlignment: (props, index, align, scrollOffset, instanceProps, scrollbarSize) => getOffsetForIndexAndAlignment("column", props, index, align, scrollOffset, instanceProps, scrollbarSize),
  getOffsetForRowAndAlignment: (props, index, align, scrollOffset, instanceProps, scrollbarSize) => getOffsetForIndexAndAlignment("row", props, index, align, scrollOffset, instanceProps, scrollbarSize),
  getRowOffset: (props, index, instanceProps) => getItemMetadata("row", props, index, instanceProps).offset,
  getRowHeight: (props, index, instanceProps) => instanceProps.rowMetadataMap[index].size,
  getRowStartIndexForOffset: (props, scrollTop, instanceProps) => findNearestItem("row", props, instanceProps, scrollTop),
  getRowStopIndexForStartIndex: (props, startIndex, scrollTop, instanceProps) => {
    const { rowCount, height } = props;
    const itemMetadata = getItemMetadata("row", props, startIndex, instanceProps);
    const maxOffset = scrollTop + height;
    let offset = itemMetadata.offset + itemMetadata.size;
    let stopIndex = startIndex;
    while (stopIndex < rowCount - 1 && offset < maxOffset) {
      stopIndex++;
      offset += getItemMetadata("row", props, stopIndex, instanceProps).size;
    }
    return stopIndex;
  },
  initInstanceProps(props, instance) {
    const { estimatedColumnWidth, estimatedRowHeight } = props;
    const instanceProps = {
      columnMetadataMap: {},
      estimatedColumnWidth: estimatedColumnWidth || DEFAULT_ESTIMATED_ITEM_SIZE,
      estimatedRowHeight: estimatedRowHeight || DEFAULT_ESTIMATED_ITEM_SIZE,
      lastMeasuredColumnIndex: -1,
      lastMeasuredRowIndex: -1,
      rowMetadataMap: {}
    };
    instance.resetAfterColumnIndex = (columnIndex, shouldForceUpdate = true) => {
      instance.resetAfterIndices({ columnIndex, shouldForceUpdate });
    };
    instance.resetAfterRowIndex = (rowIndex, shouldForceUpdate = true) => {
      instance.resetAfterIndices({ rowIndex, shouldForceUpdate });
    };
    instance.resetAfterIndices = ({
      columnIndex,
      rowIndex,
      shouldForceUpdate = true
    }) => {
      if (typeof columnIndex === "number") {
        instanceProps.lastMeasuredColumnIndex = Math.min(instanceProps.lastMeasuredColumnIndex, columnIndex - 1);
      }
      if (typeof rowIndex === "number") {
        instanceProps.lastMeasuredRowIndex = Math.min(instanceProps.lastMeasuredRowIndex, rowIndex - 1);
      }
      instance._getItemStyleCache(-1);
      if (shouldForceUpdate) {
        instance.forceUpdate();
      }
    };
    return instanceProps;
  },
  shouldResetStyleCacheOnItemSizeChange: false
});
VariableSizeGrid.prototype._getSortElement = function() {
  if (!this._sortElement) {
    this._sortElement = (0, import_react_sortable_hoc.SortableElement)(Row);
  }
  return this._sortElement;
};
VariableSizeGrid.prototype.render = function() {
  var _a, _b, _c, _d, _e, _f;
  const {
    children,
    className,
    columnCount,
    direction,
    height,
    innerRef,
    innerElementType,
    innerTagName,
    itemData = {},
    outerElementType,
    outerTagName,
    style,
    width,
    minHeight,
    virtualScrolling
  } = this.props;
  const scrollerInfo = (0, import_util.getScrollBarInfo)();
  const { rowDrag, local } = ((_a = itemData.table) == null ? void 0 : _a.props) || {};
  const addFixedColumn = itemData.fixedColumns && (itemData.fixedColumns.left.columns.length > 0 || itemData.fixedColumns.right.columns.length > 0);
  const dataSource = itemData.dataSource || [];
  const hasData = dataSource.length > 0;
  const TableRow = rowDrag ? this._getSortElement() : Row;
  const delayLoading = optimize(this);
  const [columnStartIndex, columnStopIndex] = this._getHorizontalRangeToRender();
  let [rowStartIndex, rowStopIndex] = this._getVerticalRangeToRender();
  this._rangeToRender = {
    rowIndex: [rowStartIndex, rowStopIndex],
    columnIndex: [columnStartIndex, columnStopIndex]
  };
  let totalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
  const totalWidth = getTotalWidth(this);
  const keyField = itemData.table.getKeyField();
  const aggregates = itemData.aggregates || [];
  let aggregateItems = [];
  const aggregateHeight = itemData.table.props.aggregatePosition !== "start" && aggregates.length > 0 ? Math.max(32, aggregates.length * 21 + itemData.table._getCellPadding()) : 0;
  const items = [];
  const horizontal = totalWidth > width;
  const vertical = totalHeight + aggregateHeight > Math.max(minHeight, height - (horizontal ? scrollerInfo.height : 0));
  itemData.scrollbar = { horizontal, vertical };
  const lastRowInfo = {};
  const loading = (_c = (_b = itemData == null ? void 0 : itemData.table) == null ? void 0 : _b.state) == null ? void 0 : _c.loading;
  if (columnCount >= 0 && hasData) {
    const scrollWidth = vertical ? scrollerInfo.width : 0;
    const fixedRight = width - itemData.fixedColumns.right.width - scrollWidth;
    for (let rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
      const rowItems = [];
      const cellStyle = this._getItemStyle(rowIndex, 0);
      const row = dataSource[rowIndex] || {};
      if (row.cellType === import_common.CellTypeEnum.ExpandRowCell) {
        items.push(
          (0, import_react.createElement)("div", {
            key: `expand_${row.groupIndex}`,
            children: cellStyle.height > 0 ? createCellNode({
              children,
              rowIndex: row.groupIndex,
              columnIndex: -2,
              contentWidth: width - scrollWidth,
              cellType: import_common.CellTypeEnum.ExpandRowCell,
              itemData,
              data: row.parent
            }) : null,
            className: `expand-row`,
            style: {
              position: "absolute",
              left: 0,
              width: totalWidth,
              height: cellStyle.height,
              top: cellStyle.top
            }
          })
        );
      } else if (row.cellType === import_common.CellTypeEnum.AggregateCell) {
        items.push(
          (0, import_react.createElement)("div", {
            key: `ag_${row.groupIndex}`,
            children: createAggregateItems(
              this,
              fixedRight,
              `ag_${row.groupIndex}`,
              columnStartIndex,
              columnStopIndex,
              (_d = row.parent) == null ? void 0 : _d.children
            ),
            className: `aggregates-row ag-cell`,
            style: {
              position: "absolute",
              left: 0,
              width: totalWidth,
              height: cellStyle.height,
              top: cellStyle.top
            }
          })
        );
      } else {
        if (!delayLoading) {
          addFixedColumn && rowItems.push(
            createCellNode({
              children,
              rowIndex,
              edit: true,
              cellType: import_common.CellTypeEnum.FixedBodyCell,
              fixedRight,
              itemData,
              data: itemData.dataSource[rowIndex],
              columnIndex: -1,
              style: { ...cellStyle, top: 0 }
            })
          );
          if (row[import_common.IS_GROUP]) {
            rowItems.push(
              createCellNode({
                children,
                rowIndex,
                cellType: import_common.CellTypeEnum.GroupRowCell,
                data: itemData.dataSource[rowIndex],
                itemData,
                columnIndex: 0,
                style: {
                  ...cellStyle,
                  left: 0,
                  position: "sticky",
                  top: 0,
                  width: "auto"
                }
              })
            );
          } else if (columnCount > 0) {
            for (let columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) {
              const dataIndex = itemData.columns[columnIndex].dataIndex;
              let offset = 0;
              if (itemData.columns && itemData.columns[columnIndex].mergeCell && !itemData.columns[columnIndex].editor) {
                const mergeCell = itemData.columns[columnIndex].mergeCell;
                const mergeFn = import_util.util.isFunction(mergeCell) ? mergeCell : ({ nextRow, currentRow, dataIndex: dataIndex2 }) => {
                  return currentRow[dataIndex2] === nextRow[dataIndex2];
                };
                const cellValue = row[dataIndex];
                let _info = lastRowInfo[columnIndex] || [rowIndex, cellValue, 0];
                if (_info[1] === cellValue && cellValue !== void 0) {
                  if (rowIndex < rowStopIndex && mergeFn({ nextRow: dataSource[rowIndex + 1], currentRow: row, dataIndex })) {
                    _info[2] += cellStyle.height;
                    offset = -1;
                  } else {
                    offset = _info[2];
                    _info = null;
                  }
                }
                lastRowInfo[columnIndex] = _info;
              }
              if (offset > -1) {
                rowItems.push(
                  createCellNode({
                    children,
                    rowIndex,
                    columnIndex,
                    edit: offset <= 0,
                    cellType: offset > 0 ? import_common.CellTypeEnum.MergeCell : import_common.CellTypeEnum.BodyCell,
                    itemData,
                    data: itemData.dataSource[rowIndex],
                    style: {
                      ...this._getItemStyle(rowIndex, columnIndex),
                      top: 0 - offset,
                      height: cellStyle.height + offset
                    }
                  })
                );
              }
            }
          }
        }
        const rowData = itemData.dataSource[rowIndex];
        if (rowData[keyField] === void 0) {
          rowData[keyField] = import_util.util.uniqueId(rowIndex) + "_$_";
        }
        items.push(
          /* @__PURE__ */ import_react.default.createElement(
            TableRow,
            {
              index: rowIndex,
              key: rowData[keyField],
              rowIndex,
              width: totalWidth,
              delayLoading,
              isGroup: row[import_common.IS_GROUP],
              scrollingStyle: {
                width: totalWidth,
                height: cellStyle.height
              },
              style: {
                position: "absolute",
                left: 0,
                // right: 0,
                width: totalWidth,
                height: cellStyle.height,
                top: cellStyle.top
              }
            },
            rowItems
          )
        );
      }
    }
    if (aggregateHeight > 0) {
      aggregateItems = createAggregateItems(this, fixedRight, `ag`, columnStartIndex, columnStopIndex);
    }
  } else {
    this.resetAfterRowIndex(0, false);
  }
  const bodyElement = (0, import_react.createElement)(innerElementType || innerTagName || "div", {
    children: items,
    ref: innerRef,
    style: {
      height: totalHeight,
      // pointerEvents: isScrolling ? 'none' : undefined,
      width: totalWidth
    }
  });
  const emptyData = (items.length === 0 || !hasData) && loading === false;
  let addRow;
  const opt = (_e = itemData.table.props.showRowNumber) == null ? void 0 : _e.editOptions;
  if (emptyData && opt) {
    const disableAdd = import_util.util.isFunction(opt.disabled) ? opt.disabled({ table: itemData.table, rowIndex: -1 }) : opt.disabled;
    const needAdd = !(disableAdd === true || ((_f = disableAdd == null ? void 0 : disableAdd.includes) == null ? void 0 : _f.call(disableAdd, "add")));
    if (needAdd) {
      addRow = async () => {
        if (opt.add) {
          await opt.add({ table: itemData.table, rowIndex: -1 });
        } else {
          await itemData.table.addRows({});
        }
      };
    }
  }
  return (0, import_react.createElement)(
    outerElementType || outerTagName || "div",
    {
      className,
      onScroll: this._onScroll,
      ref: this._outerRefSetter,
      style: {
        position: "relative",
        width,
        height: virtualScrolling ? height : "100%",
        WebkitOverflowScrolling: "touch",
        direction,
        ...style,
        minHeight
      }
    },
    bodyElement,
    (0, import_react.createElement)("div", {
      children: items.length === 0 && hasData && loading === false ? null : emptyData ? /* @__PURE__ */ import_react.default.createElement(
        import_antd.Empty,
        {
          image: import_antd.Empty.PRESENTED_IMAGE_SIMPLE,
          description: /* @__PURE__ */ import_react.default.createElement("span", null, local.noData || "暂无数据", addRow && /* @__PURE__ */ import_react.default.createElement("br", null), addRow && /* @__PURE__ */ import_react.default.createElement(import_Button.Button, { type: "primary", onClick: addRow, style: { marginTop: 8 } }, local.addRow || "立即新增"))
        }
      ) : aggregateItems,
      className: emptyData ? "empty-row" : aggregateItems.length > 0 ? "aggregates-row" : "",
      style: aggregateItems.length > 0 ? {
        position: "sticky",
        height: aggregateHeight,
        width: totalWidth,
        zIndex: dataSource.length * 2 + 2
      } : { position: "sticky", left: 0 }
    })
  );
};
var base_default = VariableSizeGrid;
